package com.atstudy.lambda;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/1/4 10:52
 * @copyright: 博为峰
 */
public class LamDemo {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        Supplier<Integer> supplier = new Supplier<>() {
            @Override
            public Integer get() {
                return 9;
            }
        };

        supplier = () -> 9;

        System.out.println(supplier.get());
    }

    private static void m3() {
        Consumer<String> consumer = new Consumer<>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };

        consumer = s -> System.out.println(s);

        consumer.accept("bwf");
    }

    private static void m2() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("bwf");
            }
        }).start();

        new Thread(() -> System.out.println("bwf")).start();
    }

    private static void m1() {
        ArrayList<String> list = new ArrayList<String>();
        list.add("zhangsan");
        list.add("lisi");
        list.add("wangwu");
        list.add("zhaoliu");

//        list.sort(new ComparatorByName());

//        list.sort(new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.compareTo(o2);
//            }
//        });

        list.sort((o1, o2) -> o1.compareTo(o2));

        System.out.println(list);
    }
}
